@import "../../base.less";

@import "./_var.less";

@import "../../utilities/_animation.less";

@import "../../mixins/_reset.less";

@import "../../mixins/_scrollbar.less";

.@{prefix}-tag-input {
  .reset;

  .@{prefix}-tag {
    vertical-align: middle;
    animation: t-fade-in @anim-duration-base ease-in-out;
    margin: 3px @comp-margin-xs 3px 0;
  }

  .@{prefix}-tag-input__drag_wrapper + .@{prefix}-tag-input__drag_wrapper {
    margin-left: @comp-margin-xs;
  }

  .@{prefix}-input {
    overflow: hidden;
    min-height: @tag-input-height-default;
    height: fit-content;
    padding: 0 @comp-paddingLR-s 0 @comp-margin-xs;
    .t-input-suffix-icon(@comp-margin-s);

    &.@{prefix}-size-s {
      padding: 0 @comp-paddingLR-s 0 @comp-margin-xs;
      min-height: @tag-input-height-s;
      .@{prefix}-tag {
        margin: 1px @comp-margin-xs 1px 0;
      }
    }

    &.@{prefix}-size-l {
      min-height: @tag-input-height-l;
      padding: 0 @comp-paddingLR-m 0 @comp-margin-s;
      .t-input-suffix-icon(@comp-margin-m);
    }
  }

  /** 设计稿：未填充标签场景，边距和已填充不同 */
  &.@{prefix}-is-empty {

    .@{prefix}-input__inner {
      margin-left: @comp-margin-xs;
    }
  }

  &:hover,
  .@{prefix}-input--focused {
    .@{prefix}-input__inner:not(.@{prefix}-input--soft-hidden) {
      min-width: 20px;
    }
  }

  .@{prefix}-tag-input__prefix {
    margin-left: @comp-margin-xs;
    line-height: 1;

    > .t-icon {
      color: @text-color-placeholder;
    }
  }

  .@{prefix}-input .@{prefix}-input__prefix:not(:empty) {
    margin-right: 0;
  }

  &.@{prefix}-input--auto-width {

    .@{prefix}-input.@{prefix}-input--focused {
      padding-right: @tag-input-clear-icon-padding-m;
    }

    .@{prefix}-input__prefix {
      white-space: nowrap;
    }
  }
  .@{prefix}-input__prefix--scrollable {
    .scrollbar();

    overflow-y: hidden;
    overflow-x: auto;
  }
}

.@{prefix}-tag-input__suffix-clear {
  cursor: pointer;
}

.@{prefix}-tag-input--drag-sort {
  .@{prefix}-input__prefix {
    .@{prefix}-tag {
      cursor: move;
    }
  }
}

// 标签数量超出时，换行显示
.@{prefix}-tag-input--break-line:not(.@{prefix}-is-empty) {

  .@{prefix}-input {
    display: block;

    &.@{prefix}-input--prefix > .@{prefix}-input__prefix {
      display: inline;
      text-align: left;
    }

    .@{prefix}-input__suffix-icon {
      position: absolute;
      bottom: 0;
    }
  }

  .@{prefix}-tag-input__prefix {
    vertical-align: middle;
  }
}

.@{prefix}-tag-input__prefix {
  width: max-content;
  display: inline-block;
  margin-right: @comp-margin-s;
}

/** 换行模式避免标签和右侧图标重合，需保留图标宽度 22px 和左侧距离标签间距 8px */
.@{prefix}-tag-input--break-line.@{prefix}-tag-input--with-tag:not(.@{prefix}-input--auto-width),
.@{prefix}-tag-input.@{prefix}-input--auto-width:hover {
  .@{prefix}-input {
    padding-right: @tag-input-clear-icon-padding-m;
  }

  .@{prefix}-size-l {
    .@{prefix}-input {
      padding-right: @tag-input-clear-icon-padding-l;
    }
  }
}

/** auto-width 模式，左右边距相同 */
.@{prefix}-tag-input.@{prefix}-input--auto-width {
  .@{prefix}-input {
    padding-right: 0;
  }
}

/** max-rows模式，限制最大高度 */
.@{prefix}-tag-input--max-rows {
  .@{prefix}-input {
    &.@{prefix}-size-s {
      max-height: calc(var(--max-rows, 1) * @tag-input-height-s);
    }

    &.@{prefix}-size-l {
      max-height: calc(var(--max-rows, 1) * (@tag-input-height-l - 2px));
    }

    max-height: calc(var(--max-rows, 1) * (@tag-input-height-default - 2px));
    overflow-y: scroll;
  }
}
